import type {
  ChannelSourceTrackForm,
  ChannelSourceTrackQuery,
  ChannelSourceTrackVO,
} from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 分页查询预登记渠道来源追踪列表
 * @param params
 * @returns 预登记渠道来源追踪列表
 */
export function channelSourceTrackPage(params?: ChannelSourceTrackQuery) {
  return requestClient.get<PageResult<ChannelSourceTrackVO>>(
    '/register/channel/source/track/page',
    { params },
  );
}

/**
 * 查询预登记渠道来源追踪列表
 * @param params
 * @returns 预登记渠道来源追踪列表
 */
export function channelSourceTrackList(params?: ChannelSourceTrackQuery) {
  return requestClient.get<ChannelSourceTrackVO[]>(
    '/register/channel/source/track/list',
    { params },
  );
}

/**
 * 导出预登记渠道来源追踪列表
 * @param params
 * @returns 预登记渠道来源追踪列表
 */
export function channelSourceTrackExport(params?: ChannelSourceTrackQuery) {
  return commonExport('/register/channel/source/track/export', params ?? {});
}

/**
 * 查询预登记渠道来源追踪详情
 * @param id id
 * @returns 预登记渠道来源追踪详情
 */
export function channelSourceTrackInfo(id: ID) {
  return requestClient.get<ChannelSourceTrackVO>(
    `/register/channel/source/track/${id}`,
  );
}

/**
 * 新增预登记渠道来源追踪
 * @param data
 * @returns void
 */
export function channelSourceTrackAdd(data: ChannelSourceTrackForm) {
  return requestClient.postWithMsg<void>(
    '/register/channel/source/track',
    data,
  );
}

/**
 * 更新预登记渠道来源追踪
 * @param data
 * @returns void
 */
export function channelSourceTrackUpdate(data: ChannelSourceTrackForm) {
  return requestClient.putWithMsg<void>('/register/channel/source/track', data);
}

/**
 * 更新预登记渠道来源追踪状态
 * @param data
 * @returns void
 */
export function channelSourceTrackUpdateStatus(data: ChannelSourceTrackForm) {
  return requestClient.putWithMsg<void>(
    `/register/channel/source/track/changeStatus`,
    data,
  );
}

/**
 * 删除预登记渠道来源追踪
 * @param id id
 * @returns void
 */
export function channelSourceTrackRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(
    `/register/channel/source/track/${id}`,
  );
}
